const mongoConnected = require("../lib/mongoose_connect");
const mongoModels = require("../lib/mongoose_schemas");
const lodash = require("lodash");
const fs = require("fs-extra");
const path = require("path");
const THREE = require("three");


mongoConnected.then(async $ => {
  let ddd = await mongoModels.TB21_city.find({});
  let obj = {};
  for (let zone of ddd) {
    // debugger
    let mianji = (zone.extent.x[1] - zone.extent.x[0]) * (zone.extent.y[1] - zone.extent.y[0])
    obj[zone.name_id] = {
      name: zone.name,
      down: zone.dev.zhandouliedu,
      safezone: zone.dev.safezoneval,
      items: zone.dev.item_density,
      items_attachment: zone.dev.peijian / mianji,
      items_use: zone.dev.yaopin / mianji,
      items_weapon: zone.dev.wuqi / mianji,
      grids_count: null,
      is_safe: zone.is_safe,
      is_rich: zone.is_rich
    }
  }
  await fs.writeFile(path.join(__dirname, "../test/210225_radar.json"), JSON.stringify(obj));
  debugger
})